# yun-cha-coffee PyCharm
# 2025/8/30 16:57
# YunCha-Coffee PyCharm
# user 86155
# 2025/8/30 1:15
from fastapi import APIRouter
from typing import Union,List
from app.models import *
from pydantic import BaseModel, validator

orderItem_api = APIRouter(prefix="/orderItem")

@orderItem_api.get("/",summary="查询所有订单项表")
async def getAllOrderItems():
    # 查询所有
    orderItems = await OrderItem.all()

    return {
        "code":200,
        "message":"查询成功",
        "data":orderItems
    }

@orderItem_api.get("/{id}",summary="查询某一个订单项表")
async def getOneUser(id:int):
    orderItem = await OrderItem.get(id=id)

    return {
        "code":200,
        "message":"查询成功",
        "data":orderItem
    }


@orderItem_api.post("/")
async def addOrderItem():

    return {
        "code":200,
        "message":"添加成功"
    }

@orderItem_api.delete("/{id}")
async def deleteOrderItem(id:int):
    await OrderItem.filter(id=id).delete()

    return {
        "code":200,
        "message":"删除成功"
    }

@orderItem_api.put("/{id}")
async def updateOrderItem():

    return {
        "code":200,
        "message":"修改成功"
    }
